#!/bin/sh
a=`uname  -a`
tracker_server_ip="10.206.0.17"
b="Darwin"
c="centos"
d="ubuntu"

function init() {
     mkdir sudo mkdir -p /data/fdfs/tracker
     mkdir sudo mkdir -p /data/fdfs/stroage
     tar -zxvf fastDFS-all.tar.gz
     unzip libfastcommon-master.zip
     cd libfastcommon-master/
     sudo ./make.sh && ./make.sh install
     cd ..
     tar -zxvf FastDFS_v5.08.tar.gz
     cd FastDFS
     sudo ./make.sh && ./make.sh install
     cd ..
     ll /etc/init.d/ | grep fdfs
     cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
     cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
     cp FastDFS/conf/client.conf /etc/fdfs/
     sed -i '22c base_path=/data/fdfs/tracker' /etc/fdfs/tracker.conf
     sed -i '41c base_path=/data/fdfs/stroage' /etc/fdfs/storage.conf
     sed -i '109c store_path0=/data/fdfs/stroage' /etc/fdfs/storage.conf
     sed -i '118c tracker_server='$tracker_server_ip':22122' /etc/fdfs/storage.conf
     sudo service fdfs_trackerd start
     sudo chkconfig fdfs_trackerd on
     sudo service fdfs_storaged start
     sudo chkconfig fdfs_storaged on
     tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
     sed -i 's/usr\/local/usr/g' fastdfs-nginx-module/src/config
     cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
     sed -i '10c base_path=/data/fdfs/stroage' /etc/fdfs/client.conf
     sed -i '14c tracker_server='$tracker_server_ip':22122' /etc/fdfs/client.conf
     sed -i '40c tracker_server='$tracker_server_ip':22122' /etc/fdfs/mod_fastdfs.conf
     sed -i '53c url_have_group_name=true' /etc/fdfs/mod_fastdfs.conf
     sed -i '41c store_path0=/data/fdfs/stroage' /etc/fdfs/mod_fastdfs.conf
     sed -i '62c store_path0=/data/fdfs/stroage' /etc/fdfs/mod_fastdfs.conf
     cp FastDFS/conf/mime.types  /etc/fdfs/
     cp FastDFS/conf/http.conf  /etc/fdfs/

     tar -zxvf nginx-1.10.0.tar.gz
     cd nginx-1.10.0/
     sudo ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx --add-module=../fastdfs-nginx-module/src
     sudo make && sudo make install
     sed -i '40a location ~/group([0-9])/ { \n ngx_fastdfs_module; \n }' /opt/nginx/conf/nginx.conf
     nginx
}
#centos系统
function centOs() {
     sudo yum -y install gcc
     sudo yum install -y unzip zip
     sudo yum -y install libevent
     sudo yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
}

if [[ $a =~ $b ]];then
    echo "mac"
elif [[ $a =~ $c ]];then
  echo "centos系统";
  centOs;
elif [[ $a =~ $d ]];then
    sudo apt-get install –y git
else
    echo $a
fi
init;
